home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 47.7z / BS1 part 47 / ImageMaster RT v1.50b (1994)(Black Belt Systems)(Disk 6 of 7)[HD].7z / ImageMaster RT v1.50b (1994)(Black Belt Systems)(Disk 6 of 7)[HD].adf / piarc.lzh.parta / njplr.rexx < prev   
OS/2 REXX Batch file  |  1994-03-17  |  5KB  |  143 lines

  1. /*
  2.  * njplr.rexx
  3.  *
  4.  *  Written by: Pete Patterson & Ben Williams
  5.  * Last Update: February 27th, 1993
  6.  *         For: Black Belt Systems Amiga image processing software "IM"
  7.  * --------------------------------------------------------------------
  8.  *    Revision: 2.00
  9.  */
  10.  
  11. parse arg '"' fullname '"'
  12. call pragma('stack',20000);
  13.  
  14. if ~show('L',"rexxsupport.library") then do
  15.   if ~addlib('rexxsupport.library',0,-30,0) then do
  16.     say 'We Have A Library Problem, Unable To Load "rexxsupport.library"';
  17.     say 'Cannot operate PI Modules without this library - sorry!';
  18.     'finish';
  19.     exit 10;
  20.     end;
  21.   end;
  22.  
  23. prtnme = 'IP_Port'; /* assume Image Professional */
  24. if show('P','IP_Port') = 0 then do
  25.   if show('P','IM_Port') = 0 then do
  26.     say "Can't find image processor's ARexx port!!!"; /* not running? */
  27.     say "This script requires IP, IM or IM F/c to run!";
  28.     exit(20);
  29.     end;
  30.   else do
  31.     prtnme = 'IM_Port';
  32.     end;
  33.   end;
  34.  
  35. cmdpath = 'c:';
  36. if open(fhandle,'rexx:picmdpath','read') then
  37.   do
  38.     cmdpath = readln(fhandle);
  39.     call close(fhandle);
  40.   end
  41.  
  42. if fullname = "" then
  43.   do
  44.     options results;
  45.     address command 'rx rxpi:GetFile.rexx';
  46.     if open(fhandle,'ram:IP_FNAME.tmp','read') then
  47.       do
  48.         fullname = readln(fhandle);
  49.         call close(fhandle);
  50.       end
  51.   end
  52.  
  53. thispath = gimmepath(fullname);
  54.  
  55.  
  56. /* --------------------------------------------------------------------- */
  57. /* ------------- BEGINNING of format-specific ARexx code --------------- */
  58. /* --------------------------------------------------------------------- */
  59. address command cmdpath||'NJPLRD c "'||fullname||'"';
  60. if rc ~= 0 then do; address(prtnme); 'message "Cannot read '||fullname||' Error = '||rc||'"'; 'finish'; exit 0; end;
  61. call open(fhandle,'ram:IP_LDNJPL.tmp','read'); rstring = readln(fhandle); call close(fhandle);
  62. parse var rstring width '/' height
  63. address command 'c:delete >nil: ram:IP_LDNJPL.tmp';
  64. if height < 0     then do; 'message "Bad Height:' height '"'; 'finish'; exit 0; end;
  65. if height > 32767 then do; 'message "Bad Height:' height '"'; 'finish'; exit 0; end;
  66. if width  < 0     then do; 'message "Bad Width:'  width  '"'; 'finish'; exit 0; end;
  67. if width  > 32767 then do; 'message "Bad Width:'  width  '"'; 'finish'; exit 0; end;
  68.  
  69. address(prtnme);
  70. options results;
  71. 'gadgets "Load","'||Width||' by '||Height||'","Half","Size","Quarter","Size","Eighth","Size"'
  72. pxsz = result-1;
  73.  
  74. if pxsz < 0 then do; 'finish'; exit 0; end;
  75. if pxsz = 0 then do; scl = 1; end;
  76. if pxsz = 1 then do; scl = 2; width = width / 2; height = height / 2; end;
  77. if pxsz = 2 then do; scl = 4; width = width / 4; height = height / 4; end;
  78. if pxsz = 3 then do; scl = 8; width = width / 8; height = height / 8; end;
  79.  
  80. options results; 'askyn '||'"Save Image Info as File" "Don`t Save Image Info"'; prefs = result; svinfo = 0;
  81. if prefs = 0 then do; svinfo = 1; 'filerequest "'||prevpath||'","'||bufname||'","","Save TEXT"'; njplfile2 = result; options; end;
  82.  
  83. options results;
  84. 'imtofront';
  85. 'autoredraw 0';
  86. options results;
  87. 'newtargetted '||width||' '||height||' "'||gxname||'"'
  88. if rc ~= 0 then do; 'options'; "message Can't allocate buffer!"; 'autoredraw 1'; 'finish'; exit 0; end;
  89. bnum = result;
  90. 'backin '||bnum;
  91. plugadr = result;
  92. options;
  93. 'lockimage '||bnum;
  94.  
  95. if (svinfo = 1) then do
  96.   address command cmdpath||'NJPLRD d'||plugadr||' "'||fullname||'" '||scl||' "'||njplfile2||'"'; end;
  97. else do
  98.   address command cmdpath||'NJPLRD d'||plugadr||' "'||fullname||'" '||scl; end;
  99.  
  100. 'unlockimage '||bnum;
  101. 'imtofront';
  102. 'autoredraw 1';
  103. 'finish';
  104. exit 0;
  105.  
  106. /* --------------------------------------------------------------------- */
  107. /* ---------------- END of format-specific ARexx code ------------------ */
  108. /* --------------------------------------------------------------------- */
  109.  
  110. gimmepath:
  111.   arg fullnamegx;
  112.     tempgx = reverse(fullnamegx);
  113.     lengx = length(fullnamegx);   /* get length of string */
  114.     slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
  115.     colondex = index(tempgx,':');  /* first occurance of ':' from right */
  116.     seploc = 0; /* assumes current dir, no path supplied */
  117.     if slashdex ~= 0 then do /* we assume we are in a DIR */
  118.       seploc = (lengx - slashdex)+1;
  119.       end;
  120.     else do
  121.       if colondex ~= 0 then do /* we assume we are on a device */
  122.         seploc = (lengx - colondex)+1;
  123.         end;
  124.       end;
  125.   gxname = substr(fullnamegx,seploc+1); /* if you ever need it */
  126.   gxpath = left(fullnamegx,seploc);
  127.   return(gxpath);
  128.  
  129. expandfilename:
  130.   parse arg jfile;
  131.   if index(jfile,':') = 0 then do
  132.     curdir = pragma(D);
  133.     if right(curdir,1) ~= ':' then do
  134.       if right(curdir,1) ~= '/' then do
  135.         if curdir ~= '' then do
  136.           curdir = curdir || '/';
  137.           end;
  138.         end;
  139.       end;
  140.     jfile = curdir||jfile;
  141.     end;
  142.   return(jfile);
  143.